const api = require('axios').create({
    baseURL: 'http://' + process.env.API_HOST
});

api.interceptors.response.use(response => {
    return response;
}, err => {
    let res = err.response;
    let data = res && res.data || {};

    if(data.message) {
        err.message = `[${res.status}] ${data.message}`;
    }

    throw err;
});

module.exports = api;
